

# 池子基类
class Pool:
    def __init__(self):
        pass

# id池
class IDPool(Pool):
    def __init__(self):
        super(IDPool, self).__init__()
        self.nowID = 0 # 当前ID

    # 设置一个新ID
    def getNewID(self):
        self.nowID += 1
        return self.nowID

# 设置英雄ID池
HeroIDPool = IDPool()

# 英雄类
class Hero:
    def __init__(self,name="英雄名称"):
        self.name = name
        self.id = HeroIDPool.getNewID()
        self.level = 0

    def getInfo(self):
        print("当前英雄：({}){}".format(self.id,self.name))

    def setInfo(self,name):
        self.name = name


# 英雄池
class HeroPool(Pool):
    def __init__(self):
        super(HeroPool, self).__init__()
        self.heroList = []

    # 向英雄池中创建一个新的英雄
    def createHero(self,name):
        tempHero = Hero(name=name)
        self.heroList.append(tempHero)
        print("创建新英雄{}成功".format(name))

    # 输出英雄池
    def getInfo(self):
        print("目前英雄池中共有英雄{}位\n".format(len(self.heroList)))
        for i in self.heroList:   # type: i:Hero
            i.getInfo()  # 输出英雄信息

def main():
    heroPool = HeroPool()  # 新建英雄池
    # 创建新英雄
    heroPool.createHero("盲僧")
    heroPool.createHero("诡术妖姬")
    heroPool.getInfo()





if __name__ == '__main__':
    main()